package com.tvunetworks.center.user.mapper;


import com.tvunetworks.center.common.model.LoginUser;
import com.tvunetworks.center.common.model.vo.UserInfoVo;
import com.tvunetworks.center.user.model.User;
import com.tvunetworks.center.user.model.param.PageSonUserParam;
import com.tvunetworks.center.user.model.vo.GetUserByRoleIdVo;
import com.tvunetworks.center.user.model.vo.InitOriginVo;
import com.tvunetworks.center.user.model.vo.PageUserVo;
import com.tvunetworks.center.user.model.vo.UserIdWithEmail;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
/**
 * @program:
 * @description:
 * @author HenryChen
 * @create: 5/29/2019 12:17 PM
 **/
public interface UserMapper extends Mapper<User> {


    /**
     * support用户查询用户列表
     * @param role role
     * @param email email
     * @param agreement agreement
     * @return List
     */
    List<PageUserVo> supportListUser(@Param("role") String role, @Param("email") String email, @Param("agreement") Boolean agreement);

    /**
     * admin用户查询用户列表
     * @param  userId userId
     * @param  email email
     * @return List
     */
    List<PageUserVo> adminListUser(@Param("userId") String userId, @Param("email") String email);

    /**
     *
     * @param id id
     * @return User
     */
    User getById(String id);

    /**
     * 查询Admin账户所有孩子账户的id
     * @param userId userId
     * @return List
     */
    List<String> listSonUserIds(String userId);

    /**
     * 将Admin所有孩子的userParentId置为空
     * @param userId userId
     */
    void removeSonUserParentId(String userId);

    /**
     *
     * @param email email
     * @return List
     */
    List<UserIdWithEmail> listAdminIdAndEmail(@Param("email") String email);

    /**
     *
     * @param email email
     * @return List
     */
    List<UserIdWithEmail> listUserIdAndEmail(@Param("email") String email);

    /**
     *
     * @param role role
     * @return List
     */
    List<String> listUserIdByRole(@Param("role") String role);

    /**
     *
     * @return List
     */
    List<InitOriginVo> initOriginParam();

    /**
     *
     * @return List
     */
    List<InitOriginVo> initReleaseOriginParam();
    


    /**
     //根据用户id获取用户信息
     * @param userId userId
     * @return LoginUser
     * @throws Exception 编译异常
     */
    LoginUser getLoginUserByUserId(@Param("userId")String userId) throws Exception;

    /**
     *
     * @param userId userId
     * @return LoginUser
     * @throws Exception 编译
     */
    LoginUser getParentUserByUserId(@Param("userId")String userId) throws Exception;

    /**
     *
     * @param userId userId
     * @return int
     */
    int countGlobalGridRequest(@Param("userId") String userId);

    /**
     *
     * @param userId userId
     * @return int
     */
    int countTokenRequest(@Param("userId") String userId);

    /**
     *
     * @param userId userId
     * @return int
     */
    int countMyRequest(@Param("userId") String userId);
    


    /**
     //根据父用户id查询子用户的集合
     * @param parentUserId parentUserId
     * @param search search
     * @return  List
     * @throws Exception 编译
     */
    List<LoginUser> getUserListByParentUserId(@Param("parentUserId") String parentUserId,@Param("search") String search) throws Exception;

    /**
     *
     * @param email email
     * @return List
     */
    List<String> listUserEmail(@Param("email") String email);

    /**
     * 根据admin账号的id获取其所有的子账号
     * @param param param
     * @return List
     */
    List<GetUserByRoleIdVo> pageSonUserByParentUserId(PageSonUserParam param);
    /**
     * 根据admin账号的id获取其所有的子账号 不分页
     * @param  parentUserId parentUserId
     * @return List
     */
    List<UserInfoVo> pageSonUsersByParentUserId(String parentUserId);
    /**
     * 根据admin账号的email获取id
     * @param  email email
     * @return String
     */
    String getByEmali(String email);




    /**
     //根据父账号Id,获取父账号email
     * @param userParentId userParentId
     * @return String
     */
     String  getEmailByUserParentId(@Param("userParentId") String userParentId);



    /**
     //删除tvu_bookmark_share的分享关系
     * @param userId userId
     * @param updateTime updateTime
     */
     void  updateShareByUser(@Param("userId") String userId,@Param("updateTime") Long updateTime);



    /**
     //根据父用户id查询没有分享的子账号集合
     * @param parentUserId parentUserId
     * @param search search
     * @return List
     * @throws Exception 编译
     */
    List<LoginUser> getNoShareUserListByParentUserId(@Param("parentUserId") String parentUserId,@Param("search") String search) throws Exception;

    /**
     * 获取全部admin的userid
     * @return userid集合
     */
    List<String> getAdmin();

    /**
     * 获取用户子账号的admin账号
     * @return 获取用户子账号的admin账号
     */
    List<User> getUserOfAdminAndHaveSonUser();

    /**
     * 获取support名下全部的Admin账号
     * @param userId support的userId
     * @return admin账号集合
     */
    List<User> getAdminBySupport(String userId);
}
